<?php


namespace common\models\service;


use common\models\Dis;

class DisService extends Dis
{
    /**
     * 统计
     * @param $start_time
     * @param $end_time
     * @param $campus_id
     * @return int[]
     */
    public static function statistics($start_time,$end_time,$campus_id)
    {
        $where = [];
        if ($start_time&&$end_time){
            $where = ['between','create_time',$start_time,$end_time];
        }
        $running = Dis::find()->where($where)->andWhere(['review_status'=>1])
            ->andFilterWhere(['campus_id'=>$campus_id])
            ->select(['sum(total_brokerage) as amount','count(*) as num'])
            ->asArray()->one();
        $amount = $running['amount']??0;
        $num = $running['num']??0;
        return ['amount'=>$amount,'num'=>$num];
    }
}